#include <vector>
#include <iostream>
using namespace std;

class Solution 
{
public:
    vector<vector<int>> ret;
    vector<int> path;
    vector<vector<int>> subsets(vector<int>& nums) 
    {
        dfs(nums, 0);
        return ret;
    }
    void dfs(vector<int>& nums, int i)
    {
        // 递归出口
        if(i == nums.size())
        {
            ret.emplace_back(path);
            return;
        }
        // 选
        path.emplace_back(nums[i]);
        dfs(nums, i + 1);
        // 回溯
        path.pop_back();
        // 不选
        dfs(nums, i + 1);
    }
};

#if 0
class Solution 
{
public:
    vector<vector<int>> ret;
    vector<int> path;
    vector<vector<int>> subsets(vector<int>& nums) 
    {
        dfs(nums, 0);
        return ret;
    }
    void dfs(vector<int>& nums, int i)
    {
       ret.emplace_back(path);
       for(int j = i; j < nums.size(); ++j)
       {
            path.emplace_back(nums[j]);
            dfs(nums, j + 1);
            path.pop_back();
       }
    }
};
#endif



int main()
{
    vector<int> nums = {1, 2, 3};
    Solution().subsets(nums);
    return 0;
}